//sp.title=$("#ctxName").val();
require(['jquery','app', 'cookie','lay'], function ($) {
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#upicon' //绑定元素
            ,url: configPro.server_img_interface //上传接口
            ,done: function(res){
                $("#ICON").attr("src",res.data.src);
                $("#F_ICON").val(res.data.src);
            }
            ,error: function(res){
                alr("上传失败");
            }
        });
    });
    layui.use('form', function () {
        var form = layui.form;
        form.render();
        form.on('submit(formDemo)', function (data) {
            var jon = data.field;
            if(jon['password']!=jon["password2"]){
                alr("两次输入密码不一致！")
                return false;
            }
            var re=playAjax("/UserController/UpdateUser",jon);
            alr(re.msg)
            if(re.code=200){
                setTimeout(function () {
                    window.location.reload();
                },500);
            }
            return false;
        });
    })
    layui.use('layim', function (layim) {
        //基础配置
        layim.config({

            //初始化接口
            init: {
                url: 'UserController/GetMITeacher'
                , data: {
                }
            },
            isImage:false
            , initSkin: '2.jpg' //1-5 设置初始背景
            ,isgroup: false //是否开启群组
            , notice: true //是否开启桌面消息提醒，默认false
            ,voice:"https://kainuo.vip:447/kainuo/default.mp3"
        });
        //监听layim建立就绪
        layim.on('ready', function (res) {
            $(".layim-tool-about").hide();
            var re = playAjax("MessageController/GetMyMessage").data;
            if(re!=null&&re.length>0){
                debugger;
                for(var i=0;i<re.length;i++){
                    layim.getMessage(re[i]);
                }
            }
            setInterval(function () {
                var rt = playAjax("MessageController/GetMyMessage").data;
                if(rt!=null&&rt.length>0){
                    for(var i=0;i<rt.length;i++){
                        layim.getMessage(rt[i]);
                    }
                }
            }, 50000);
        });
        //监听发送消息
        layim.on('sendMessage', function (data) {
            var re = playAjax("MessageController/SetMessage",{user:{uuid:data.to.id},message:data.mine.content});
        });
        layim.on('chatChange', function(res){
            $(".layim-tool-image").hide();
        })
    });
});
menuList=playAjax("/CommonController/GetNavigation").data;
playAjax("UserController/isLogin")